<?php
/*
 * @author: ChenGuangHui
 */
/*
 * @author: ChenGuangHui
 */

namespace App\Models\Order;


use App\Models\Model;

/**
 * App\Models\Order\BlindBoxOrder
 *
 * @property int $order_id
 * @property int $uid 用户id
 * @property string $order_no 订单号
 * @property int $goods_id 商品Id
 * @property int|null $rule_type 规则ID
 * @property string $goods_name 商品名称
 * @property string $goods_thumb 商品封面
 * @property string $status 订单状态[1、未付款，2、已付款，3、未发货，4、已发货，5、交易成功，6、交易关闭]
 * @property string|null $amount 实际支付金额
 * @property string $sku 规格
 * @property int $number 购买数量
 * @property string $goods_price 商品价格
 * @property string $contact 收货人
 * @property string $moblie 手机号码
 * @property string|null $shipping_name 物流名称
 * @property string|null $shipping_code 物流单号
 * @property string|null $address 收货地址
 * @property string|null $close_time 交易关闭时间
 * @property string|null $end_time 交易完成时间
 * @property string|null $payment_time 付款时间
 * @property string|null $consign_time 发货时间
 * @property string|null $create_time 订单创建时间
 * @property string|null $post_fee 邮费
 * @property \Illuminate\Support\Carbon $created_at 创建时间
 * @property \Illuminate\Support\Carbon $updated_at 修改时间
 * @property-read mixed $status_name
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder query()
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereAddress($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereAmount($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereCloseTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereConsignTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereContact($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereCreateTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereEndTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereGoodsId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereGoodsName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereGoodsPrice($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereGoodsThumb($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereMoblie($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereNumber($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereOrderId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereOrderNo($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder wherePaymentTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder wherePostFee($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereRuleType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereShippingCode($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereShippingName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereSku($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereUid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlindBoxOrder whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class BlindBoxOrder extends Model
{
    protected $connection = 'store';
    
    protected $table = 'store_blind_box_order';

    protected $primaryKey = 'order_id';

    protected $appends = ['status_name'];

    // 订单状态[1、未付款，2、已付款，3、未发货，4、已发货，5、交易成功，6、交易关闭]
    const WAIT_PAID_ORDER = 1;
    const SUCCESS_PAID_ORDER = 2;
    const WAIT_SHIPPED_ORDER = 3;
    const HAVE_SHIPPED_ORDER = 4;
    const TRADING_SUCCESS_ORDER = 5;
    const TRADING_CLOSED_ORDER = 6;

     // 订单状态
     public static $status = [
        self::WAIT_PAID_ORDER         =>      '未付款',
        self::SUCCESS_PAID_ORDER      =>      '已付款',
        self::WAIT_SHIPPED_ORDER      =>      '未发货',
        self::HAVE_SHIPPED_ORDER      =>      '已发货',
        self::TRADING_SUCCESS_ORDER   =>      '交易成功',
        self::TRADING_CLOSED_ORDER    =>      '交易关闭',
    ];

    /**
     * @author ChenGuangHui
     * @dateTime 2022-05-07
     */
    public function getStatusNameAttribute()
    {
        return isset($this->attributes['status']) ? self::$status[$this->attributes['status']] : '待处理';
    }
}